// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.

import "babel-polyfill"
import Vue from 'vue'
import App from './App'
import axios from 'axios'
import qs from 'qs'
import store from './store/index'
import router from './router/index'
import VueLazyload from "vue-lazyload"
import pluginsComponent from "./assets/js/plugins-component"
import VueBridgeWebviewNew from './assets/js/vue-bridge-webview'
import moment from 'moment'

Vue.filter('datefmt',function(input,fmtstring){
  return moment(input).format(fmtstring)
})

//Schart图表
import Schart from 'vue-schart'
Vue.component('schart', Schart)


// qs 插件
Vue.prototype.$qs = qs

// loading图片
Vue.use(VueLazyload, {
  preLoad: 1.3, // 预加载高度比例
  loading: 'static/images/loading.png', //这个是加载的loading过渡效果
  error: 'static/images/loading.png',
  attempt: 1
})

// 注册桥
Vue.use(VueBridgeWebviewNew)
// console.log(Vue.bridge);

// 公共组件
Vue.use(pluginsComponent)



//全局注册，使用方法为:this.$axios
Vue.prototype.$axios = axios
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
axios.defaults.timeout = 3000;
// console.log(axios.defaults);

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  return config;
}, function (error) {
  return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  return response;
}, function (error) {
  return Promise.reject(error);
});


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {App},
  template: '<App/>'
});
